{% set pypi_name = 'pyghmi' %}
{% set upstream_version = upstream_version('1.5.19') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        General Hardware Management Initiative (IPMI and others)
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('cryptography') }}
BuildRequires:  {{ py3('devel') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('python-dateutil') }}
BuildRequires:  {{ py3('stestr') }}
BuildArch:      noarch

%description
This is a pure python implementation of IPMI protocol.

pyghmicons and pyghmiutil are example scripts to show how one may incorporate
this library into python code

%package -n {{ py2name(py_versions='py3') }}
Summary:        General Hardware Management Initiative (IPMI and others)
Requires:       {{ py3('cryptography')  }}
Requires:       {{ py3('python-dateutil') }}
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 1.6.0
%endif

%description -n {{ py2name(py_versions='py3') }}
This is a pure python implementation of IPMI protocol.

pyghmicons and pyghmiutil are example scripts to show how one may incorporate
this library into python code

This package contains the Python 3.x module.

%package -n python-pyghmi-doc
Summary:        General Hardware Management Initiative (IPMI and others) -- Documentation
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}

%description -n python-pyghmi-doc
This is a pure python implementation of IPMI protocol.

pyghmicons and pyghmiutil are example scripts to show how one may incorporate
this library into python code

%prep
%autosetup -p1 -n {{ pypi_name }}-%{version}
%py_req_cleanup

%build
%{py3_build}
PYTHONPATH=. PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%doc README.md ChangeLog
%license LICENSE
%{_bindir}/pyghmicons
%{_bindir}/pyghmiutil
%{_bindir}/virshbmc
%{_bindir}/fakebmc
%{python3_sitelib}/pyghmi*
%{python3_sitelib}/*.egg-info

%files -n python-pyghmi-doc
%doc doc/build/html
%license LICENSE

%changelog
